package org.kimoji.show.service;

import java.util.List;

import org.kimoji.comment.dao.CommentDAO;
import org.kimoji.entity.Album;
import org.kimoji.entity.Item;
import org.kimoji.entity.biz.ItemBiz;
import org.kimoji.search.Searcher;
import org.kimoji.show.dao.ShowDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ShowService {
	
	@Autowired
	private ShowDAO showDAO;
	@Autowired
	private Searcher searcher;
	@Autowired
	private CommentDAO commentDAO;
	
	public List<ItemBiz> show(int order,String category,int index,String keyword){
		
//		SearchData searchData = new SearchData();
//		searchData = searcher.search(searchData);
//		List<Document> documents = searchData.getDocuments();
		
		int[] ids = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
		return showDAO.getItemByIds(ids);
	}
	
	public List<Album> showAlbum(int order,String category,int index,String keyword){
		int[] ids = {1,2,3};
		return showDAO.getAlbumByIds(ids);
	}
	
	public Album getAlbum(int id){
		return showDAO.getAlbumById(id);
	}
	
	public List<ItemBiz> showSeek(int order,String category,int index,String keyword){
		return null;
	}
	
	@SuppressWarnings("unchecked")
	public List<Item> hotResource(){
		int[] ids = {1,2,3,4,5};
		List<? extends Item> list = showDAO.getItemByIds(ids);
		return (List<Item>) list;
	}
	
	public List<Album> hotAlbum(){
		int[] ids = {1,2,3};
		return showDAO.getAlbumByIds(ids);
	}
	
	@SuppressWarnings("unchecked")
	public List<Item> newResource(){
		int[] ids = {1,2,3,4,5};
		List<? extends Item> list = showDAO.getItemByIds(ids);
		return (List<Item>) list;
	}
	
	@SuppressWarnings("unchecked")
	public List<Item> relativeResource(Item item){
		int[] ids = {1,2,3,4,5};
		List<? extends Item> list = showDAO.getItemByIds(ids);
		return (List<Item>) list;
	}
	
	@SuppressWarnings("unchecked")
	public List<Item> recommendResource(Item item){
		int[] ids = {1,2,3,4,5};
		List<? extends Item> list = showDAO.getItemByIds(ids);
		return (List<Item>) list;
	}
	
	public List<Album> recommendAlbum(Album Album){
		int[] ids = {1,2,3};
		return showDAO.getAlbumByIds(ids);
	}
	
	public ItemBiz showForDetail(String id){
		ItemBiz itemBiz = showDAO.getItemById(Boolean.TRUE,id);
		int commentSize = commentDAO.getCommentSizeByItemId(id);
		itemBiz.setCommentSize(commentSize);
		return itemBiz;
	}
	
	public ItemBiz showForDialog(String id){
		return showDAO.getItemById(Boolean.FALSE,id);
	}
	
}
